home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / chasecam.zip / QC106.ZIP / CLIENT.QC < prev    next >
Text File  |  1997-04-20  |  34KB  |  1,493 lines

  1.  
  2. // prototypes
  3. void () W_WeaponFrame;
  4. void() W_SetCurrentAmmo;
  5. void() player_pain;
  6. void() player_stand1;
  7. void (vector org) spawn_tfog;
  8. void (vector org, entity death_owner) spawn_tdeath;
  9.  
  10. float    modelindex_eyes, modelindex_player;
  11.  
  12. /*
  13. =============================================================================
  14.  
  15.                 LEVEL CHANGING / INTERMISSION
  16.  
  17. =============================================================================
  18. */
  19.  
  20. float    intermission_running;
  21. float    intermission_exittime;
  22.  
  23. /*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16)
  24. This is the camera point for the intermission.
  25. Use mangle instead of angle, so you can set pitch or roll as well as yaw.  'pitch roll yaw'
  26. */
  27. void() info_intermission =
  28. {
  29. };
  30.  
  31.  
  32.  
  33. void() SetChangeParms =
  34. {
  35.     if (self.health <= 0)
  36.     {
  37.         SetNewParms ();
  38.         return;
  39.     }
  40.  
  41. // remove items
  42.     self.items = self.items - (self.items &
  43.     (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) );
  44.  
  45. // cap super health
  46.     if (self.health > 100)
  47.         self.health = 100;
  48.     if (self.health < 50)
  49.         self.health = 50;
  50.     parm1 = self.items;
  51.     parm2 = self.health;
  52.     parm3 = self.armorvalue;
  53.     if (self.ammo_shells < 25)
  54.         parm4 = 25;
  55.     else
  56.         parm4 = self.ammo_shells;
  57.     parm5 = self.ammo_nails;
  58.     parm6 = self.ammo_rockets;
  59.     parm7 = self.ammo_cells;
  60.     parm8 = self.weapon;
  61.     parm9 = self.armortype * 100;
  62.  
  63.     // ### chasecam mod ###
  64.     // holds current state of cam and targeter between levels
  65.     parm16 = self.dest2_x; // bit flags
  66.     parm14 = self.dest2_y; // cam distance
  67.     parm15 = self.dest2_z; // cam height
  68.  
  69.     parm13 = self.dest1_y; // mskin pro
  70. };
  71.  
  72. void() SetNewParms =
  73. {
  74.     local float cv;
  75.  
  76.     parm1 = IT_SHOTGUN | IT_AXE;
  77.     parm2 = 100;
  78.     parm3 = 0;
  79.     parm4 = 25;
  80.     parm5 = 0;
  81.     parm6 = 0;
  82.     parm7 = 0;
  83.     parm8 = 1;
  84.     parm9 = 0;
  85.  
  86.     // ### chasecam mod ###
  87.     // only reset if zeroed  (so DM/COOP respawns don't reset)
  88.     if (! parm14) parm14 = 100; // dist - cam distance
  89.     if (! parm15) parm15 = 0.22; //zmult - cam height offset
  90.     if (! parm16)
  91.     {
  92.         cv = cvar( "temp1" );
  93.         if (cv == 100)    parm16 = CHSCAM_ON;
  94.         if (cv == 101) parm16 = HUD_ON;
  95.         if (cv == 102) parm16 = LASERTARG_ON;
  96.         /////////////////////////////////////
  97.         if (cv == 103) parm16 = CHSCAM_ON | LASERTARG_ON;
  98.         if (cv == 104) parm16 = LASERTARG_ON | HUD_ON;
  99.         if (cv == 105) parm16 = HUD_ON | CHSCAM_ON;
  100.         /////////////////////////////////////
  101.         if (cv == 106) parm16 = LASERTARG_ON | HUD_ON | CHSCAM_ON;
  102.     }
  103.  
  104. };
  105.  
  106. void() DecodeLevelParms =
  107. {
  108.     if (serverflags)
  109.     {
  110.         if (world.model == "maps/start.bsp")
  111.             SetNewParms ();        // take away all stuff on starting new episode
  112.     }
  113.  
  114.     self.items = parm1;
  115.     self.health = parm2;
  116.     self.armorvalue = parm3;
  117.     self.ammo_shells = parm4;
  118.     self.ammo_nails = parm5;
  119.     self.ammo_rockets = parm6;
  120.     self.ammo_cells = parm7;
  121.     self.weapon = parm8;
  122.     self.armortype = parm9 * 0.01;
  123.  
  124.     // ### chasecam mod ###
  125.     if (! self.dest1_y) self.dest1_y = parm13; // mskin pro
  126.  
  127.     if (! self.dest2_x) self.dest2_x = parm16;
  128.     if (! self.dest2_y) self.dest2_y = parm14;
  129.     if (! self.dest2_z) self.dest2_z = parm15;
  130.     // sync health check variable so HUD doesn't print on startup
  131.     self.dest1_x = self.health;
  132. };
  133.  
  134. /*
  135. ============
  136. FindIntermission
  137.  
  138. Returns the entity to view from
  139. ============
  140. */
  141. entity() FindIntermission =
  142. {
  143.     local    entity spot;
  144.     local    float cyc;
  145.  
  146. // look for info_intermission first
  147.     spot = find (world, classname, "info_intermission");
  148.     if (spot)
  149.     {    // pick a random one
  150.         cyc = random() * 4;
  151.         while (cyc > 1)
  152.         {
  153.             spot = find (spot, classname, "info_intermission");
  154.             if (!spot)
  155.                 spot = find (spot, classname, "info_intermission");
  156.             cyc = cyc - 1;
  157.         }
  158.         return spot;
  159.     }
  160.  
  161. // then look for the start position
  162.     spot = find (world, classname, "info_player_start");
  163.     if (spot)
  164.         return spot;
  165.  
  166. // testinfo_player_start is only found in regioned levels
  167.     spot = find (world, classname, "testplayerstart");
  168.     if (spot)
  169.         return spot;
  170.     
  171.     objerror ("FindIntermission: no spot");
  172. };
  173.  
  174.  
  175. string nextmap;
  176. void() GotoNextMap =
  177. {
  178.     if (cvar("samelevel"))    // if samelevel is set, stay on same level
  179.         changelevel (mapname);
  180.     else
  181.         changelevel (nextmap);
  182. };
  183.  
  184.  
  185. void() ExitIntermission =
  186. {
  187. // skip any text in deathmatch
  188.     if (deathmatch)
  189.     {
  190.         GotoNextMap ();
  191.         return;
  192.     }
  193.     
  194.     intermission_exittime = time + 1;
  195.     intermission_running = intermission_running + 1;
  196.  
  197. //
  198. // run some text if at the end of an episode
  199. //
  200.     if (intermission_running == 2)
  201.     {
  202.         if (world.model == "maps/e1m7.bsp")
  203.         {
  204.             WriteByte (MSG_ALL, SVC_CDTRACK);
  205.             WriteByte (MSG_ALL, 2);
  206.             WriteByte (MSG_ALL, 3);
  207.             if (!cvar("registered"))
  208.             {
  209.                 WriteByte (MSG_ALL, SVC_FINALE);
  210.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task in the other three\nhaunted lands of Quake. Or are you? If\nyou don't register Quake, you'll never\nknow what awaits you in the Realm of\nBlack Magic, the Netherworld, and the\nElder World!");
  211.             }
  212.             else
  213.             {
  214.                 WriteByte (MSG_ALL, SVC_FINALE);
  215.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task. A Rune of magic\npower lies at the end of each haunted\nland of Quake. Go forth, seek the\ntotality of the four Runes!");
  216.             }
  217.             return;
  218.         }
  219.         else if (world.model == "maps/e2m6.bsp")
  220.         {
  221.             WriteByte (MSG_ALL, SVC_CDTRACK);
  222.             WriteByte (MSG_ALL, 2);
  223.             WriteByte (MSG_ALL, 3);
  224.  
  225.             WriteByte (MSG_ALL, SVC_FINALE);
  226.             WriteString (MSG_ALL, "The Rune of Black Magic throbs evilly in\nyour hand and whispers dark thoughts\ninto your brain. You learn the inmost\nlore of the Hell-Mother; Shub-Niggurath!\nYou now know that she is behind all the\nterrible plotting which has led to so\nmuch death and horror. But she is not\ninviolate! Armed with this Rune, you\nrealize that once all four Runes are\ncombined, the gate to Shub-Niggurath's\nPit will open, and you can face the\nWitch-Goddess herself in her frightful\notherworld cathedral.");
  227.             return;
  228.         }
  229.         else if (world.model == "maps/e3m6.bsp")
  230.         {
  231.             WriteByte (MSG_ALL, SVC_CDTRACK);
  232.             WriteByte (MSG_ALL, 2);
  233.             WriteByte (MSG_ALL, 3);
  234.  
  235.             WriteByte (MSG_ALL, SVC_FINALE);
  236.             WriteString (MSG_ALL, "The charred viscera of diabolic horrors\nbubble viscously as you seize the Rune\nof Hell Magic. Its heat scorches your\nhand, and its terrible secrets blight\nyour mind. Gathering the shreds of your\ncourage, you shake the devil's shackles\nfrom your soul, and become ever more\nhard and determined to destroy the\nhideous creatures whose mere existence\nthreatens the souls and psyches of all\nthe population of Earth.");
  237.             return;
  238.         }
  239.         else if (world.model == "maps/e4m7.bsp")
  240.         {
  241.             WriteByte (MSG_ALL, SVC_CDTRACK);
  242.             WriteByte (MSG_ALL, 2);
  243.             WriteByte (MSG_ALL, 3);
  244.  
  245.             WriteByte (MSG_ALL, SVC_FINALE);
  246.             WriteString (MSG_ALL, "Despite the awful might of the Elder\nWorld, you have achieved the Rune of\nElder Magic, capstone of all types of\narcane wisdom. Beyond good and evil,\nbeyond life and death, the Rune\npulsates, heavy with import. Patient and\npotent, the Elder Being Shub-Niggurath\nweaves her dire plans to clear off all\nlife from the Earth, and bring her own\nfoul offspring to our world! For all the\ndwellers in these nightmare dimensions\nare her descendants! Once all Runes of\nmagic power are united, the energy\nbehind them will blast open the Gateway\nto Shub-Niggurath, and you can travel\nthere to foil the Hell-Mother's plots\nin person.");
  247.             return;
  248.         }
  249.  
  250.         GotoNextMap();
  251.     }
  252.  
  253.     if (intermission_running == 3)
  254.     {
  255.         if (!cvar("registered"))
  256.         {    // shareware episode has been completed, go to sell screen
  257.             WriteByte (MSG_ALL, SVC_SELLSCREEN);
  258.             return;
  259.         }
  260.         
  261.         if ( (serverflags&15) == 15)
  262.         {
  263.             WriteByte (MSG_ALL, SVC_FINALE);
  264.             WriteString (MSG_ALL, "Now, you have all four Runes. You sense\ntremendous invisible forces moving to\nunseal ancient barriers. Shub-Niggurath\nhad hoped to use the Runes Herself to\nclear off the Earth, but now instead,\nyou will use them to enter her home and\nconfront her as an avatar of avenging\nEarth-life. If you defeat her, you will\nbe remembered forever as the savior of\nthe planet. If she conquers, it will be\nas if you had never been born.");
  265.             return;
  266.         }
  267.         
  268.     }
  269.  
  270.     GotoNextMap();
  271. };
  272.  
  273. /*
  274. ============
  275. IntermissionThink
  276.  
  277. When the player presses attack or jump, change to the next level
  278. ============
  279. */
  280. void() IntermissionThink =
  281. {
  282.     if (time < intermission_exittime)
  283.         return;
  284.  
  285.     if (!self.button0 && !self.button1 && !self.button2)
  286.         return;
  287.     
  288.     ExitIntermission ();
  289. };
  290.  
  291. void() execute_changelevel =
  292. {
  293.     local entity    pos;
  294.  
  295.     intermission_running = 1;
  296.     
  297. // enforce a wait time before allowing changelevel
  298.     if (deathmatch)
  299.         intermission_exittime = time + 5;
  300.     else
  301.         intermission_exittime = time + 2;
  302.  
  303.     WriteByte (MSG_ALL, SVC_CDTRACK);
  304.     WriteByte (MSG_ALL, 3);
  305.     WriteByte (MSG_ALL, 3);
  306.     
  307.     pos = FindIntermission ();
  308.  
  309.     other = find (world, classname, "player");
  310.     while (other != world)
  311.     {
  312.         other.view_ofs = '0 0 0';
  313.         other.angles = other.v_angle = pos.mangle;
  314.         other.fixangle = TRUE;        // turn this way immediately
  315.         other.nextthink = time + 0.5;
  316.         other.takedamage = DAMAGE_NO;
  317.         other.solid = SOLID_NOT;
  318.         other.movetype = MOVETYPE_NONE;
  319.         other.modelindex = 0;
  320.         setorigin (other, pos.origin);
  321.         other = find (other, classname, "player");
  322.     }    
  323.  
  324.     WriteByte (MSG_ALL, SVC_INTERMISSION);
  325. };
  326.  
  327.  
  328. void() changelevel_touch =
  329. {
  330.     local entity    pos;
  331.  
  332.     if (other.classname != "player")
  333.         return;
  334.  
  335.     if ((cvar("noexit") == 1) || ((cvar("noexit") == 2) && (mapname != "start")))
  336.     {
  337.         T_Damage (other, self, self, 50000);
  338.         return;
  339.     }
  340.  
  341.     if (coop || deathmatch)
  342.     {
  343.         bprint (other.netname);
  344.         bprint (" exited the level\n");
  345.     }
  346.     
  347.     nextmap = self.map;
  348.  
  349.     SUB_UseTargets ();
  350.  
  351.     if ( (self.spawnflags & 1) && (deathmatch == 0) )
  352.     {    // NO_INTERMISSION
  353.         GotoNextMap();
  354.         return;
  355.     }
  356.     
  357.     self.touch = SUB_Null;
  358.  
  359. // we can't move people right now, because touch functions are called
  360. // in the middle of C movement code, so set a think time to do it
  361.     self.think = execute_changelevel;
  362.     self.nextthink = time + 0.1;
  363. };
  364.  
  365. /*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION
  366. When the player touches this, he gets sent to the map listed in the "map" variable.  Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats.
  367. */
  368. void() trigger_changelevel =
  369. {
  370.     if (!self.map)
  371.         objerror ("chagnelevel trigger doesn't have map");
  372.     
  373.     InitTrigger ();
  374.     self.touch = changelevel_touch;
  375. };
  376.  
  377.  
  378. /*
  379. =============================================================================
  380.  
  381.                 PLAYER GAME EDGE FUNCTIONS
  382.  
  383. =============================================================================
  384. */
  385.  
  386. void() set_suicide_frame;
  387.  
  388. // called by ClientKill and DeadThink
  389. void() respawn =
  390. {
  391.     if (coop)
  392.     {
  393.         // make a copy of the dead body for appearances sake
  394.         CopyToBodyQue (self);
  395.         // get the spawn parms as they were at level start
  396.         setspawnparms (self);
  397.         // respawn
  398.         PutClientInServer ();
  399.     }
  400.     else if (deathmatch)
  401.     {
  402.         // make a copy of the dead body for appearances sake
  403.         CopyToBodyQue (self);
  404.         // set default spawn parms
  405.         SetNewParms ();
  406.         // respawn        
  407.         PutClientInServer ();
  408.     }
  409.     else
  410.     {    // restart the entire server
  411.         localcmd ("restart\n");
  412.     }
  413. };
  414.  
  415.  
  416. /*
  417. ============
  418. ClientKill
  419.  
  420. Player entered the suicide command
  421. ============
  422. */
  423. void() ClientKill =
  424. {
  425.     bprint (self.netname);
  426.     bprint (" suicides\n");
  427.     set_suicide_frame ();
  428.     self.modelindex = modelindex_player;
  429.     self.frags = self.frags - 2;    // extra penalty
  430.     respawn ();
  431. };
  432.  
  433. float(vector v) CheckSpawnPoint =
  434. {
  435.     return FALSE;
  436. };
  437.  
  438. /*
  439. ============
  440. SelectSpawnPoint
  441.  
  442. Returns the entity to spawn at
  443. ============
  444. */
  445. entity() SelectSpawnPoint =
  446. {
  447.     local    entity spot;
  448.     local    entity thing;
  449.     local    float  pcount;
  450.     
  451. // testinfo_player_start is only found in regioned levels
  452.     spot = find (world, classname, "testplayerstart");
  453.     if (spot)
  454.         return spot;
  455.  
  456. // choose a info_player_deathmatch point
  457.     if (coop)
  458.     {
  459.         lastspawn = find(lastspawn, classname, "info_player_coop");
  460.         if (lastspawn == world)
  461.             lastspawn = find (lastspawn, classname, "info_player_start");
  462.         if (lastspawn != world)
  463.             return lastspawn;
  464.     }
  465.     else if (deathmatch)
  466.     {
  467.         spot = lastspawn;
  468.         while (1)
  469.         {
  470.             spot = find(spot, classname, "info_player_deathmatch");
  471.             if (spot != world)
  472.             {
  473.                 if (spot == lastspawn)
  474.                     return lastspawn;
  475.                 pcount = 0;
  476.                 thing = findradius(spot.origin, 32);
  477.                 while(thing)
  478.                 {
  479.                     if (thing.classname == "player")
  480.                         pcount = pcount + 1;
  481.                     thing = thing.chain;
  482.                 }
  483.                 if (pcount == 0)
  484.                 {
  485.                     lastspawn = spot;
  486.                     return spot;
  487.                 }
  488.             }
  489.         }
  490.     }
  491.  
  492.     if (serverflags)
  493.     {    // return with a rune to start
  494.         spot = find (world, classname, "info_player_start2");
  495.         if (spot)
  496.             return spot;
  497.     }
  498.  
  499.     spot = find (world, classname, "info_player_start");
  500.     if (!spot)
  501.         error ("PutClientInServer: no info_player_start on level");
  502.     
  503.     return spot;
  504. };
  505.  
  506. /*
  507. ===========
  508. PutClientInServer
  509.  
  510. called each time a player is spawned
  511. ============
  512. */
  513. void() DecodeLevelParms;
  514. void() PlayerDie;
  515.  
  516. // ### chasecam mod ###
  517. void() Chase_cam_level_start;
  518.  
  519. void() PutClientInServer =
  520. {
  521.     local    entity spot;
  522.  
  523.     spot = SelectSpawnPoint ();
  524.  
  525.     self.classname = "player";
  526.     self.health = 100;
  527.     self.takedamage = DAMAGE_AIM;
  528.     self.solid = SOLID_SLIDEBOX;
  529.     self.movetype = MOVETYPE_WALK;
  530.     self.show_hostile = 0;
  531.     self.max_health = 100;
  532.     self.flags = FL_CLIENT;
  533.     self.air_finished = time + 12;
  534.     self.dmg = 2;           // initial water damage
  535.     self.super_damage_finished = 0;
  536.     self.radsuit_finished = 0;
  537.     self.invisible_finished = 0;
  538.     self.invincible_finished = 0;
  539.     self.effects = 0;
  540.     self.invincible_time = 0;
  541.  
  542.     DecodeLevelParms ();
  543.     
  544.     W_SetCurrentAmmo ();
  545.  
  546.     self.attack_finished = time;
  547.     self.th_pain = player_pain;
  548.     self.th_die = PlayerDie;
  549.  
  550.     self.deadflag = DEAD_NO;
  551. // paustime is set by teleporters to keep the player from moving a while
  552.     self.pausetime = 0;
  553.  
  554. //    spot = SelectSpawnPoint ();
  555.  
  556.     self.origin = spot.origin + '0 0 1';
  557.     self.angles = spot.angles;
  558.     self.fixangle = TRUE;        // turn this way immediately
  559.  
  560. // oh, this is a hack!
  561.     setmodel (self, "progs/eyes.mdl");
  562.     modelindex_eyes = self.modelindex;
  563.  
  564.     setmodel (self, "progs/player.mdl");
  565.     modelindex_player = self.modelindex;
  566.  
  567.     setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
  568.  
  569.     self.view_ofs = '0 0 22';
  570.  
  571.     player_stand1 ();
  572.  
  573.     if (deathmatch || coop)
  574.     {
  575.         makevectors(self.angles);
  576.         spawn_tfog (self.origin + v_forward*20);
  577.     }
  578.  
  579.     spawn_tdeath (self.origin, self);
  580.  
  581.     // ### chasecam mod ###
  582.     // reset view and targeter according to what was set in parm16
  583.     Chase_cam_level_start();
  584.  
  585. };
  586.  
  587.  
  588. /*
  589. =============================================================================
  590.  
  591.                 QUAKED FUNCTIONS
  592.  
  593. =============================================================================
  594. */
  595.  
  596.  
  597. /*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24)
  598. The normal starting point for a level.
  599. */
  600. void() info_player_start =
  601. {
  602. };
  603.  
  604.  
  605. /*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24)
  606. Only used on start map for the return point from an episode.
  607. */
  608. void() info_player_start2 =
  609. {
  610. };
  611.  
  612.  
  613. /*
  614. saved out by quaked in region mode
  615. */
  616. void() testplayerstart =
  617. {
  618. };
  619.  
  620. /*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24)
  621. potential spawning position for deathmatch games
  622. */
  623. void() info_player_deathmatch =
  624. {
  625. };
  626.  
  627. /*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24)
  628. potential spawning position for coop games
  629. */
  630. void() info_player_coop =
  631. {
  632. };
  633.  
  634. /*
  635. ===============================================================================
  636.  
  637. RULES
  638.  
  639. ===============================================================================
  640. */
  641.  
  642. /*
  643. go to the next level for deathmatch
  644. only called if a time or frag limit has expired
  645. */
  646. void() NextLevel =
  647. {
  648.     local entity o;
  649.  
  650.     if (mapname == "start")
  651.     {
  652.         if (!cvar("registered"))
  653.         {
  654.             mapname = "e1m1";
  655.         }
  656.         else if (!(serverflags & 1))
  657.         {
  658.             mapname = "e1m1";
  659.             serverflags = serverflags | 1;
  660.         }
  661.         else if (!(serverflags & 2))
  662.         {
  663.             mapname = "e2m1";
  664.             serverflags = serverflags | 2;
  665.         }
  666.         else if (!(serverflags & 4))
  667.         {
  668.             mapname = "e3m1";
  669.             serverflags = serverflags | 4;
  670.         }
  671.         else if (!(serverflags & 8))
  672.         {
  673.             mapname = "e4m1";
  674.             serverflags = serverflags - 7;
  675.         }
  676.  
  677.         o = spawn();
  678.         o.map = mapname;
  679.     }
  680.     else
  681.     {
  682.         // find a trigger changelevel
  683.         o = find(world, classname, "trigger_changelevel");
  684.  
  685.         // go back to start if no trigger_changelevel
  686.         if (!o)
  687.         {
  688.             mapname = "start";
  689.             o = spawn();
  690.             o.map = mapname;
  691.         }
  692.     }
  693.  
  694.     nextmap = o.map;
  695.     gameover = TRUE;
  696.  
  697.     if (o.nextthink < time)
  698.     {
  699.         o.think = execute_changelevel;
  700.         o.nextthink = time + 0.1;
  701.     }
  702. };
  703.  
  704. /*
  705. ============
  706. CheckRules
  707.  
  708. Exit deathmatch games upon conditions
  709. ============
  710. */
  711. void() CheckRules =
  712. {
  713.     local    float        timelimit;
  714.     local    float        fraglimit;
  715.     
  716.     if (gameover)    // someone else quit the game already
  717.         return;
  718.         
  719.     timelimit = cvar("timelimit") * 60;
  720.     fraglimit = cvar("fraglimit");
  721.     
  722.     if (timelimit && time >= timelimit)
  723.     {
  724.         NextLevel ();
  725.         return;
  726.     }
  727.     
  728.     if (fraglimit && self.frags >= fraglimit)
  729.     {
  730.         NextLevel ();
  731.         return;
  732.     }    
  733. };
  734.  
  735. //============================================================================
  736.  
  737. void() PlayerDeathThink =
  738. {
  739.     local entity    old_self;
  740.     local float        forward;
  741.  
  742.     if ((self.flags & FL_ONGROUND))
  743.     {
  744.         forward = vlen (self.velocity);
  745.         forward = forward - 20;
  746.         if (forward <= 0)
  747.             self.velocity = '0 0 0';
  748.         else    
  749.             self.velocity = forward * normalize(self.velocity);
  750.     }
  751.  
  752. // wait for all buttons released
  753.     if (self.deadflag == DEAD_DEAD)
  754.     {
  755.         if (self.button2 || self.button1 || self.button0)
  756.             return;
  757.         self.deadflag = DEAD_RESPAWNABLE;
  758.         return;
  759.     }
  760.  
  761. // wait for any button down
  762.     if (!self.button2 && !self.button1 && !self.button0)
  763.         return;
  764.  
  765.     self.button0 = 0;
  766.     self.button1 = 0;
  767.     self.button2 = 0;
  768.     respawn();
  769. };
  770.  
  771.  
  772. void() PlayerJump =
  773. {
  774.     local vector start, end;
  775.     
  776.     if (self.flags & FL_WATERJUMP)
  777.         return;
  778.     
  779.     if (self.waterlevel >= 2)
  780.     {
  781.         if (self.watertype == CONTENT_WATER)
  782.             self.velocity_z = 100;
  783.         else if (self.watertype == CONTENT_SLIME)
  784.             self.velocity_z = 80;
  785.         else
  786.             self.velocity_z = 50;
  787.  
  788. // play swiming sound
  789.         if (self.swim_flag < time)
  790.         {
  791.             self.swim_flag = time + 1;
  792.             if (random() < 0.5)
  793.                 sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
  794.             else
  795.                 sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
  796.         }
  797.  
  798.         return;
  799.     }
  800.  
  801.     if (!(self.flags & FL_ONGROUND))
  802.         return;
  803.  
  804.     if ( !(self.flags & FL_JUMPRELEASED) )
  805.         return;        // don't pogo stick
  806.  
  807.     self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  808.  
  809.     self.flags = self.flags - FL_ONGROUND;    // don't stairwalk
  810.     
  811.     self.button2 = 0;
  812. // player jumping sound
  813.     sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
  814.     self.velocity_z = self.velocity_z + 270;
  815. };
  816.  
  817.  
  818. /*
  819. ===========
  820. WaterMove
  821.  
  822. ============
  823. */
  824. .float    dmgtime;
  825.  
  826. void() WaterMove =
  827. {
  828. //dprint (ftos(self.waterlevel));
  829.     if (self.movetype == MOVETYPE_NOCLIP)
  830.         return;
  831.     if (self.health < 0)
  832.         return;
  833.  
  834.     if (self.waterlevel != 3)
  835.     {
  836.         if (self.air_finished < time)
  837.             sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
  838.         else if (self.air_finished < time + 9)
  839.             sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
  840.         self.air_finished = time + 12;
  841.         self.dmg = 2;
  842.     }
  843.     else if (self.air_finished < time)
  844.     {    // drown!
  845.         if (self.pain_finished < time)
  846.         {
  847.             self.dmg = self.dmg + 2;
  848.             if (self.dmg > 15)
  849.                 self.dmg = 10;
  850.             T_Damage (self, world, world, self.dmg);
  851.             self.pain_finished = time + 1;
  852.         }
  853.     }
  854.     
  855.     if (!self.waterlevel)
  856.     {
  857.         if (self.flags & FL_INWATER)
  858.         {    
  859.             // play leave water sound
  860.             sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
  861.             self.flags = self.flags - FL_INWATER;
  862.         }
  863.         return;
  864.     }
  865.  
  866.     if (self.watertype == CONTENT_LAVA)
  867.     {    // do damage
  868.         if (self.dmgtime < time)
  869.         {
  870.             if (self.radsuit_finished > time)
  871.                 self.dmgtime = time + 1;
  872.             else
  873.                 self.dmgtime = time + 0.2;
  874.  
  875.             T_Damage (self, world, world, 10*self.waterlevel);
  876.         }
  877.     }
  878.     else if (self.watertype == CONTENT_SLIME)
  879.     {    // do damage
  880.         if (self.dmgtime < time && self.radsuit_finished < time)
  881.         {
  882.             self.dmgtime = time + 1;
  883.             T_Damage (self, world, world, 4*self.waterlevel);
  884.         }
  885.     }
  886.     
  887.     if ( !(self.flags & FL_INWATER) )
  888.     {    
  889.  
  890. // player enter water sound
  891.  
  892.         if (self.watertype == CONTENT_LAVA)
  893.             sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
  894.         if (self.watertype == CONTENT_WATER)
  895.             sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
  896.         if (self.watertype == CONTENT_SLIME)
  897.             sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
  898.  
  899.         self.flags = self.flags + FL_INWATER;
  900.         self.dmgtime = 0;
  901.     }
  902.     
  903.     if (! (self.flags & FL_WATERJUMP) )
  904.         self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
  905. };
  906.  
  907. void() CheckWaterJump =
  908. {
  909.     local vector start, end;
  910.  
  911. // check for a jump-out-of-water
  912.     makevectors (self.angles);
  913.     start = self.origin;
  914.     start_z = start_z + 8; 
  915.     v_forward_z = 0;
  916.     normalize(v_forward);
  917.     end = start + v_forward*24;
  918.     traceline (start, end, TRUE, self);
  919.     if (trace_fraction < 1)
  920.     {    // solid at waist
  921.         start_z = start_z + self.maxs_z - 8;
  922.         end = start + v_forward*24;
  923.         self.movedir = trace_plane_normal * -50;
  924.         traceline (start, end, TRUE, self);
  925.         if (trace_fraction == 1)
  926.         {    // open at eye level
  927.             self.flags = self.flags | FL_WATERJUMP;
  928.             self.velocity_z = 225;
  929.             self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  930.             self.teleport_time = time + 2;    // safety net
  931.             return;
  932.         }
  933.     }
  934. };
  935.  
  936.  
  937. /*
  938. ================
  939. PlayerPreThink
  940.  
  941. Called every frame before physics are run
  942. ================
  943. */
  944. void() PlayerPreThink =
  945. {
  946.     local    float    mspeed, aspeed;
  947.     local    float    r;
  948.  
  949.     if (intermission_running)
  950.     {
  951.         IntermissionThink ();    // otherwise a button could be missed between
  952.         return;                    // the think tics
  953.     }
  954.  
  955.     if (self.view_ofs == '0 0 0')
  956.         return;        // intermission or finale
  957.  
  958.     makevectors (self.v_angle);        // is this still used
  959.  
  960.     CheckRules ();
  961.     WaterMove ();
  962.  
  963.     if (self.waterlevel == 2)
  964.         CheckWaterJump ();
  965.  
  966.     if (self.deadflag >= DEAD_DEAD)
  967.     {
  968.         PlayerDeathThink ();
  969.         return;
  970.     }
  971.     
  972.     if (self.deadflag == DEAD_DYING)
  973.         return;    // dying, so do nothing
  974.  
  975.     if (self.button2)
  976.     {
  977.         PlayerJump ();
  978.     }
  979.     else
  980.         self.flags = self.flags | FL_JUMPRELEASED;
  981.  
  982. // teleporters can force a non-moving pause time    
  983.     if (time < self.pausetime)
  984.         self.velocity = '0 0 0';
  985.  
  986.     if(time > self.attack_finished && self.currentammo == 0 && self.weapon != IT_AXE)
  987.     {
  988.         self.weapon = W_BestWeapon ();
  989.         W_SetCurrentAmmo ();
  990.     }
  991. };
  992.  
  993. /*
  994. ================
  995. CheckPowerups
  996.  
  997. Check for turning off powerups
  998. ================
  999. */
  1000. void() CheckPowerups =
  1001. {
  1002.     if (self.health <= 0)
  1003.         return;
  1004.  
  1005. // invisibility
  1006.     if (self.invisible_finished)
  1007.     {
  1008. // sound and screen flash when items starts to run out
  1009.         if (self.invisible_sound < time)
  1010.         {
  1011.             sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE);
  1012.             self.invisible_sound = time + ((random() * 3) + 1);
  1013.         }
  1014.  
  1015.  
  1016.         if (self.invisible_finished < time + 3)
  1017.         {
  1018.             if (self.invisible_time == 1)
  1019.             {
  1020.                 sprint (self, "Ring of Shadows magic is fading\n");
  1021.                 stuffcmd (self, "bf\n");
  1022.                 sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM);
  1023.                 self.invisible_time = time + 1;
  1024.             }
  1025.  
  1026.             if (self.invisible_time < time)
  1027.             {
  1028.                 self.invisible_time = time + 1;
  1029.                 stuffcmd (self, "bf\n");
  1030.             }
  1031.         }
  1032.  
  1033.         if (self.invisible_finished < time)
  1034.         {    // just stopped
  1035.             self.items = self.items - IT_INVISIBILITY;
  1036.             self.invisible_finished = 0;
  1037.             self.invisible_time = 0;
  1038.         }
  1039.  
  1040.     // use the eyes
  1041.         self.frame = 0;
  1042.         self.modelindex = modelindex_eyes;
  1043.     }
  1044.     else
  1045.         self.modelindex = modelindex_player;    // don't use eyes
  1046.  
  1047. // invincibility
  1048.     if (self.invincible_finished)
  1049.     {
  1050. // sound and screen flash when items starts to run out
  1051.         if (self.invincible_finished < time + 3)
  1052.         {
  1053.             if (self.invincible_time == 1)
  1054.             {
  1055.                 sprint (self, "Protection is almost burned out\n");
  1056.                 stuffcmd (self, "bf\n");
  1057.                 sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
  1058.                 self.invincible_time = time + 1;
  1059.             }
  1060.  
  1061.             if (self.invincible_time < time)
  1062.             {
  1063.                 self.invincible_time = time + 1;
  1064.                 stuffcmd (self, "bf\n");
  1065.             }
  1066.         }
  1067.  
  1068.         if (self.invincible_finished < time)
  1069.         {    // just stopped
  1070.             self.items = self.items - IT_INVULNERABILITY;
  1071.             self.invincible_time = 0;
  1072.             self.invincible_finished = 0;
  1073.         }
  1074.         if (self.invincible_finished > time)
  1075.             self.effects = self.effects | EF_DIMLIGHT;
  1076.         else
  1077.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1078.     }
  1079.  
  1080. // super damage
  1081.     if (self.super_damage_finished)
  1082.     {
  1083.  
  1084. // sound and screen flash when items starts to run out
  1085.  
  1086.         if (self.super_damage_finished < time + 3)
  1087.         {
  1088.             if (self.super_time == 1)
  1089.             {
  1090.                 sprint (self, "Quad Damage is wearing off\n");
  1091.                 stuffcmd (self, "bf\n");
  1092.                 sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
  1093.                 self.super_time = time + 1;
  1094.             }
  1095.  
  1096.             if (self.super_time < time)
  1097.             {
  1098.                 self.super_time = time + 1;
  1099.                 stuffcmd (self, "bf\n");
  1100.             }
  1101.         }
  1102.  
  1103.         if (self.super_damage_finished < time)
  1104.         {    // just stopped
  1105.             self.items = self.items - IT_QUAD;
  1106.             self.super_damage_finished = 0;
  1107.             self.super_time = 0;
  1108.         }
  1109.         if (self.super_damage_finished > time)
  1110.             self.effects = self.effects | EF_DIMLIGHT;
  1111.         else
  1112.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1113.     }
  1114.  
  1115. // suit
  1116.     if (self.radsuit_finished)
  1117.     {
  1118.         // ### chasecam mod ###
  1119.         self.skin = 21;  // biosuit skin
  1120.  
  1121.         self.air_finished = time + 12;        // don't drown
  1122.  
  1123. // sound and screen flash when items starts to run out
  1124.         if (self.radsuit_finished < time + 3)
  1125.         {
  1126.             if (self.rad_time == 1)
  1127.             {
  1128.                 sprint (self, "Air supply in Biosuit expiring\n");
  1129.                 stuffcmd (self, "bf\n");
  1130.                 sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM);
  1131.                 self.rad_time = time + 1;
  1132.             }
  1133.  
  1134.             if (self.rad_time < time)
  1135.             {
  1136.                 self.rad_time = time + 1;
  1137.                 stuffcmd (self, "bf\n");
  1138.             }
  1139.         }
  1140.  
  1141.         if (self.radsuit_finished < time)
  1142.         {    // just stopped
  1143.  
  1144.             // ### chasecam mod ###
  1145.             self.skin = self.dest1_y; // back to old skin
  1146.  
  1147.             self.items = self.items - IT_SUIT;
  1148.             self.rad_time = 0;
  1149.             self.radsuit_finished = 0;
  1150.         }
  1151.     }
  1152.  
  1153. };
  1154.  
  1155.  
  1156. /*
  1157. ================
  1158. PlayerPostThink
  1159.  
  1160. Called every frame after physics are run
  1161. ================
  1162. */
  1163. void() PlayerPostThink =
  1164. {
  1165.     local    float    mspeed, aspeed;
  1166.     local    float    r;
  1167.  
  1168.     if (self.view_ofs == '0 0 0')
  1169.         return;        // intermission or finale
  1170.     if (self.deadflag)
  1171.         return;
  1172.         
  1173. // do weapon stuff
  1174.  
  1175.     W_WeaponFrame ();
  1176.  
  1177. // check to see if player landed and play landing sound    
  1178.     if ((self.jump_flag < -300) && (self.flags & FL_ONGROUND) && (self.health > 0))
  1179.     {
  1180.         if (self.watertype == CONTENT_WATER)
  1181.             sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
  1182.         else if (self.jump_flag < -650)
  1183.         {
  1184.             T_Damage (self, world, world, 5); 
  1185.             sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  1186.             self.deathtype = "falling";
  1187.         }
  1188.         else
  1189.             sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  1190.  
  1191.         self.jump_flag = 0;
  1192.     }
  1193.  
  1194.     if (!(self.flags & FL_ONGROUND))
  1195.         self.jump_flag = self.velocity_z;
  1196.  
  1197.     CheckPowerups ();
  1198. };
  1199.  
  1200.  
  1201. /*
  1202. ===========
  1203. ClientConnect
  1204.  
  1205. called when a player connects to a server
  1206. ============
  1207. */
  1208. void() ClientConnect =
  1209. {
  1210.     bprint (self.netname);
  1211.     bprint (" entered the game\n");
  1212.     
  1213. // a client connecting during an intermission can cause problems
  1214.     if (intermission_running)
  1215.         ExitIntermission ();
  1216. };
  1217.  
  1218.  
  1219. /*
  1220. ===========
  1221. ClientDisconnect
  1222.  
  1223. called when a player disconnects from a server
  1224. ============
  1225. */
  1226. void() ClientDisconnect =
  1227. {
  1228.     if (gameover)
  1229.         return;
  1230.     // if the level end trigger has been activated, just return
  1231.     // since they aren't *really* leaving
  1232.  
  1233.     // let everyone else know
  1234.     bprint (self.netname);
  1235.     bprint (" left the game with ");
  1236.     bprint (ftos(self.frags));
  1237.     bprint (" frags\n");
  1238.     sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
  1239.     set_suicide_frame ();
  1240. };
  1241.  
  1242. /*
  1243. ===========
  1244. ClientObituary
  1245.  
  1246. called when a player dies
  1247. ============
  1248. */
  1249. void(entity targ, entity attacker) ClientObituary =
  1250. {
  1251.     local    float rnum;
  1252.     local    string deathstring, deathstring2;
  1253.     rnum = random();
  1254.  
  1255.     if (targ.classname == "player")
  1256.     {
  1257.         if (attacker.classname == "teledeath")
  1258.         {
  1259.             bprint (targ.netname);
  1260.             bprint (" was telefragged by ");
  1261.             bprint (attacker.owner.netname);
  1262.             bprint ("\n");
  1263.  
  1264.             attacker.owner.frags = attacker.owner.frags + 1;
  1265.             return;
  1266.         }
  1267.  
  1268.         if (attacker.classname == "teledeath2")
  1269.         {
  1270.             bprint ("Satan's power deflects ");
  1271.             bprint (targ.netname);
  1272.             bprint ("'s telefrag\n");
  1273.  
  1274.             targ.frags = targ.frags - 1;
  1275.             return;
  1276.         }
  1277.  
  1278.         if (attacker.classname == "player")
  1279.         {
  1280.             if (targ == attacker)
  1281.             {
  1282.                 // killed self
  1283.                 attacker.frags = attacker.frags - 1;
  1284.                 bprint (targ.netname);
  1285.                 
  1286.                 if (targ.weapon == 64 && targ.waterlevel > 1)
  1287.                 {
  1288.                     bprint (" discharges into the water.\n");
  1289.                     return;
  1290.                 }
  1291.                 if (targ.weapon == IT_GRENADE_LAUNCHER)
  1292.                     bprint (" tries to put the pin back in\n");
  1293.                 else
  1294.                     bprint (" becomes bored with life\n");
  1295.                 return;
  1296.             }
  1297.             else if ( (teamplay == 2) && (targ.team > 0)&&(targ.team == attacker.team) )
  1298.             {
  1299.                 if (rnum < 0.25)
  1300.                     deathstring = " mows down a teammate\n";
  1301.                 else if (rnum < 0.50)
  1302.                     deathstring = " checks his glasses\n";
  1303.                 else if (rnum < 0.75)
  1304.                     deathstring = " gets a frag for the other team\n";
  1305.                 else
  1306.                     deathstring = " loses another friend\n";
  1307.                 bprint (attacker.netname);
  1308.                 bprint (deathstring);
  1309.                 attacker.frags = attacker.frags - 1;
  1310.                 return;
  1311.             }
  1312.             else
  1313.             {
  1314.                 attacker.frags = attacker.frags + 1;
  1315.  
  1316.                 rnum = attacker.weapon;
  1317.                 if (rnum == IT_AXE)
  1318.                 {
  1319.                     deathstring = " was ax-murdered by ";
  1320.                     deathstring2 = "\n";
  1321.                 }
  1322.                 if (rnum == IT_SHOTGUN)
  1323.                 {
  1324.                     deathstring = " chewed on ";
  1325.                     deathstring2 = "'s boomstick\n";
  1326.                 }
  1327.                 if (rnum == IT_SUPER_SHOTGUN)
  1328.                 {
  1329.                     deathstring = " ate 2 loads of ";
  1330.                     deathstring2 = "'s buckshot\n";
  1331.                 }
  1332.                 if (rnum == IT_NAILGUN)
  1333.                 {
  1334.                     deathstring = " was nailed by ";
  1335.                     deathstring2 = "\n";
  1336.                 }
  1337.                 if (rnum == IT_SUPER_NAILGUN)
  1338.                 {
  1339.                     deathstring = " was punctured by ";
  1340.                     deathstring2 = "\n";
  1341.                 }
  1342.                 if (rnum == IT_GRENADE_LAUNCHER)
  1343.                 {
  1344.                     deathstring = " eats ";
  1345.                     deathstring2 = "'s pineapple\n";
  1346.                     if (targ.health < -40)
  1347.                     {
  1348.                         deathstring = " was gibbed by ";
  1349.                         deathstring2 = "'s grenade\n";
  1350.                     }
  1351.                 }
  1352.                 if (rnum == IT_ROCKET_LAUNCHER)
  1353.                 {
  1354.                     deathstring = " rides ";
  1355.                     deathstring2 = "'s rocket\n";
  1356.                     if (targ.health < -40)
  1357.                     {
  1358.                         deathstring = " was gibbed by ";
  1359.                         deathstring2 = "'s rocket\n" ;
  1360.                     }
  1361.                 }
  1362.                 if (rnum == IT_LIGHTNING)
  1363.                 {
  1364.                     deathstring = " accepts ";
  1365.                     if (attacker.waterlevel > 1)
  1366.                         deathstring2 = "'s discharge\n";
  1367.                     else
  1368.                         deathstring2 = "'s shaft\n";
  1369.                 }
  1370.                 bprint (targ.netname);
  1371.                 bprint (deathstring);
  1372.                 bprint (attacker.netname);
  1373.                 bprint (deathstring2);
  1374.             }
  1375.             return;
  1376.         }
  1377.         else
  1378.         {
  1379.             targ.frags = targ.frags - 1;
  1380.             bprint (targ.netname);
  1381.  
  1382.             // killed by a montser?
  1383.             if (attacker.flags & FL_MONSTER)
  1384.             {
  1385.                 if (attacker.classname == "monster_army")
  1386.                     bprint (" was shot by a Grunt\n");
  1387.                 if (attacker.classname == "monster_demon1")
  1388.                     bprint (" was eviscerated by a Fiend\n");
  1389.                 if (attacker.classname == "monster_dog")
  1390.                     bprint (" was mauled by a Rottweiler\n");
  1391.                 if (attacker.classname == "monster_dragon")
  1392.                     bprint (" was fried by a Dragon\n");
  1393.                 if (attacker.classname == "monster_enforcer")
  1394.                     bprint (" was blasted by an Enforcer\n");
  1395.                 if (attacker.classname == "monster_fish")
  1396.                     bprint (" was fed to the Rotfish\n");
  1397.                 if (attacker.classname == "monster_hell_knight")
  1398.                     bprint (" was slain by a Death Knight\n");
  1399.                 if (attacker.classname == "monster_knight")
  1400.                     bprint (" was slashed by a Knight\n");
  1401.                 if (attacker.classname == "monster_ogre")
  1402.                     bprint (" was destroyed by an Ogre\n");
  1403.                 if (attacker.classname == "monster_oldone")
  1404.                     bprint (" became one with Shub-Niggurath\n");
  1405.                 if (attacker.classname == "monster_shalrath")
  1406.                     bprint (" was exploded by a Vore\n");
  1407.                 if (attacker.classname == "monster_shambler")
  1408.                     bprint (" was smashed by a Shambler\n");
  1409.                 if (attacker.classname == "monster_tarbaby")
  1410.                     bprint (" was slimed by a Spawn\n");
  1411.                 if (attacker.classname == "monster_vomit")
  1412.                     bprint (" was vomited on by a Vomitus\n");
  1413.                 if (attacker.classname == "monster_wizard")
  1414.                     bprint (" was scragged by a Scrag\n");
  1415.                 if (attacker.classname == "monster_zombie")
  1416.                     bprint (" joins the Zombies\n");
  1417.  
  1418.                 return;
  1419.             }
  1420.  
  1421.             // tricks and traps
  1422.             if (attacker.classname == "explo_box")
  1423.             {
  1424.                 bprint (" blew up\n");
  1425.                 return;
  1426.             }
  1427.             if (attacker.solid == SOLID_BSP && attacker != world)
  1428.             {    
  1429.                 bprint (" was squished\n");
  1430.                 return;
  1431.             }
  1432.             if (attacker.classname == "trap_shooter" || attacker.classname == "trap_spikeshooter")
  1433.             {
  1434.                 bprint (" was spiked\n");
  1435.                 return;
  1436.             }
  1437.             if (attacker.classname == "fireball")
  1438.             {
  1439.                 bprint (" ate a lavaball\n");
  1440.                 return;
  1441.             }
  1442.             if (attacker.classname == "trigger_changelevel")
  1443.             {
  1444.                 bprint (" tried to leave\n");
  1445.                 return;
  1446.             }
  1447.  
  1448.             // in-water deaths
  1449.             rnum = targ.watertype;
  1450.             if (rnum == -3)
  1451.             {
  1452.                 if (random() < 0.5)
  1453.                     bprint (" sleeps with the fishes\n");
  1454.                 else
  1455.                     bprint (" sucks it down\n");
  1456.                 return;
  1457.             }
  1458.             else if (rnum == -4)
  1459.             {
  1460.                 if (random() < 0.5)
  1461.                     bprint (" gulped a load of slime\n");
  1462.                 else
  1463.                     bprint (" can't exist on slime alone\n");
  1464.                 return;
  1465.             }
  1466.             else if (rnum == -5)
  1467.             {
  1468.                 if (targ.health < -15)
  1469.                 {
  1470.                     bprint (" burst into flames\n");
  1471.                     return;
  1472.                 }
  1473.                 if (random() < 0.5)
  1474.                     bprint (" turned into hot slag\n");
  1475.                 else
  1476.                     bprint (" visits the Volcano God\n");
  1477.                 return;
  1478.             }
  1479.  
  1480.             // fell to their death?
  1481.             if (targ.deathtype == "falling")
  1482.             {
  1483.                 targ.deathtype = "";
  1484.                 bprint (" fell to his death\n");
  1485.                 return;
  1486.             }
  1487.  
  1488.             // hell if I know; he's just dead!!!
  1489.             bprint (" died\n");
  1490.         }
  1491.     }
  1492. };
  1493.